package com.cooge.jiexi;

import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class pptv {
	
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {
		String html = NetUtil.getHtml("http://play.api.pptv.com/boxplay.api?id=23609865&type=phone.ios&gslbversion=2&ft=2&version=4&userLevel=1&appver=4.2.5&appid=com.pptv.iphoneapp");
		html = html.substring(html.indexOf("<root"),html.lastIndexOf("root>")+"root>".length());
		Document doc = DocumentHelper.parseText(html);
		Element rootlele = doc.getRootElement();
		List<Element> dts = rootlele.elements("dt");
		List<Element> items = rootlele.element("channel").element("file").elements();
		
		
		for(int i = 0 ;i<items.size();i++){
			
			Element item = items.get(i);
			
			Element dt = dts.get(i);
			
			String  ip =  dt.element("sh").getText();
			
			String  id =  dt.element("id").getText();
			
			String  key  =  dt.element("key").getText();
			
			String rid = item.attributeValue("rid");
			
			String videoUrl = "http://"+ip+"/w/"+rid+"?type=phone.ios&key="+id+"&k="+key;
			
			System.out.println(videoUrl);
		}
		
		
		//http://112.80.40.41/w/9edf57d44da576b425deba84d039e2fc.mp4?type=phone.ios&key=23a4887a2680c1cb16ffc3b4cd44235a&k=3ebe627c83102847ad44fdf436327eee-8fdd-1435665417
		//http://112.80.40.39/w/9edf57d44da576b425deba84d039e2fc.mp4?type=phone.ios&key=23a4887a2680c1cb16ffc3b4cd44235a&k=ec1e13d3480ddae18da2671b373674d3-b2f9-1435669224
		//http://124.160.184.187/w/65f90dc8c48f243d0d46f6a423e98819.mp4?type=phone.ios&key=23a4887a2680c1cb16ffc3b4cd44235a&k=3832c810f28b0363fe86d2f73eb3afdc-b2f9-1435669224
		
		
	}

}
